﻿@using BI.CF.PageList
@using BI.CF.Model
@model BI.CF.PageList.Pager<RepayDetailedModel>
@{
    ViewBag.Title = "RepayDetailedShow";
    Layout = "~/Views/Shared/MyAccount.cshtml";
}
@{
    BI.CF.PageList.Pager<RepayDetailedModel> m = Model as BI.CF.PageList.Pager<RepayDetailedModel>;
    var Uid = Session["UserID"];
}
    <script src="~/_files/WdatePicker.js"></script>
<script src="~/Content/Command.js"></script>
<link href="~/_files/WdatePicker.css" rel="stylesheet" />
<script src="~/Content/BootstrapSouce/js/jquery.min.js"></script>
<script src="~/Content/BootstrapSouce/js/bootstrap.min.js"></script>
<link href="~/Content/BootstrapSouce/css/bootstrap.min.css" rel="stylesheet" />
    <div class="MycoentRight lf">

    <div  class="MyTabMuen">
        <ul>
            <li class="curt"><a href="/uac/debit/listForRepaymentPlan">还款明细</a><span></span></li>
        </ul>
        <div class="clear"></div>
    </div>
    <div class="height"></div>
    <div class="RepaymentPlan">
        <div class="my_Search">
            <ul>
                <li>
                    <span class="lf">
                        还款时间：<input type="date" style="width:150px;" class="Wdate txt_100" value="2017-02-07" id="StartDate" name="startTime">-
                        <input type="date" style="width:150px;" class="Wdate txt_100" value="2017-05-07" id="EndDate" name="endTime">
                    </span>
                    <span class="lf"><input type="submit" value="搜 索" class="Flat_but" id="Search"> <input type="button" onclick="exportRepaymentPlanListsToExcel();" value="导出excel表单" class="Flat_but"></span>
                </li>
            </ul>
            <div class="clear"></div>
        </div>
        <div class="Result_tj" id="DivShow" ></div>
     
            <table cellspacing="0" cellpadding="0" class="table_list" style=" width:910px; font-size:12px;" id="TAB"></table>
            <table id="tab"></table>


        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            &times;
                        </button>
                        <h4 class="modal-title" id="myModalLabel"></h4>
                    </div>
                    <div id="xiangqing_huiyuan" class="modal-body">

                        <!--模态框标头显示-->
                        <ul id="myTab" class="nav nav-tabs">
                            <li class="active">
                                <a href="#" data-toggle="tab">
                                    还款信息
                                </a>
                            </li>
                        </ul>
                        <!-- 模态框内容显示 -->
                        <div id="myTabContent" class="tab-content">
                            <!-- 还款详情 -->
                            <div class="tab-pane fade in active" id="home">
                                <table class="table">
                                    <tr>
                                        <td>
                                            还款人
                                        </td>
                                        <td>
                                            <input type="text" readonly id="UUserNames" value="" />
                                            <input type="hidden" id="UserId" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            还款标题
                                        </td>
                                        <td>
                                            <input type="text" readonly id="title3" value="" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            还款时间
                                        </td>
                                        <td>
                                            <input type="text" readonly value="@DateTime.Now" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            本期应还本息
                                        </td>
                                        <td>
                                            <input type="text" readonly id="RepaymentMoney1" value="" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            还款金额
                                        </td>
                                        <td>
                                            <input type="text" readonly id="URechargeMoney" value="" />
                                            <input type="hidden" id="Rid" value="" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            支付密码
                                        </td>
                                        <td>
                                            <input type="password" id="Pwd" />
                                            <span id="spans"></span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td><input type="button" style="width:150px;height:60px; font-size:20px;" name="name" value="提交" onclick="UpdRechargeRecord()" class="btn btn-primary" /></td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                     <!--模态框的尾部-->
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">
                            关闭
                        </button>
                        <!--  <button type="button" class="btn btn-primary">
                            提交更改
                        </button>  -->
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
        </div>
        @*<div class="Result_tj">
                <span>结果统计：待还本息<b class="red">￥0.00</b></span>
                <span>违约金总额：<b class="red">￥0.00</b></span>
                <span>催收费用总额：<b class="red">￥0.00</b></span>
                (<span>可用余额：<b class="red">￥0.00</b></span>)
            </div>
            <textarea id="template" style="display:none">
                <table cellspacing="0" cellpadding="0" class="table_list" style=" width:928px; font-size:12px;">
                    <tr class="">
                        <th style="width:200px;">借款标题</th>
                        <th style="width:70px;">第几期</th>
                        <th style="width:100px;">还款日期</th>
                        <th style="width:120px;">本期应还本息</th>
                        <th style="width:120px;">违约金</th>
                        <th style="width:120px;">催收费</th>
                        <th style="width:110px;">状态</th>
                        <th style="width:90px;">操作</th>
                    </tr>
                    {#foreach $T as list}

                    <tr>
                        <td class="cz"><a href="https://investment.my089.com/credit/forBidding?sid={$T.list.subjectId}" class="f_blue" target="_blank">{$T.list.title}</a></td>
                        <td>{$T.list.sequenceTerm}</td>
                        <td>{$T.list.planTimeAsString}</td>
                        <td>{$T.list.planAmountAsString}</td>
                        <td>{$T.list.lateFeeDesc}</td>
                        <td>{$T.list.penaltyAsString}</td>
                        <td>{$T.list.repaymentStatusAsString}</td>
                        <td id="CZ_{$T.list.subjectId}" class="cz">
                            {#if $T.list.pageStatus ==1  }
                            <a onclick="return repayMent('{$T.list.subjectId}','{$T.list.originId}',0);" href="javascript:void(0);">还款</a>
                            {#elseif $T.list.pageStatus == 0  }
                            {#/if}
                        </td>
                    </tr>
                    {#/for}
                </table>
            </textarea>*@
        <div class="yema rt"></div><div class="clear"></div>
        <div class="clear"></div>
    </div>
    <div id="pageResult"></div>
    <div id="pageNavTool"></div>
    <div class="clear"></div>
        <script>

    $(function () {
        page(1)
    });
    function page(i) {
        var TimeMin = $("#StartDate").val();
        var TimeMax = $("#EndDate").val();
        $.getJSON("/RepayDetailed/RepayDetailedShowDo", {
            datemin: TimeMin,
            datemax: TimeMax,
            Mid: 1,
            Uid: 1,
            pageindex: i,
            pagesize: 10
        }, function (data) {

            for (var i = 0; i < data.Data.length; i++) {
                var sp = "<span>结果统计：待还本息<b class='red'>￥" + data.Data[i].RepaymentMoney + "</b></span><span>违约金总额：<b class='red'>￥" + data.Data[i].OverdueForfeit + "</b></span><span>催收费用总额：<b class='red'>￥" + data.Data[i].RushFee + "</b></span>";
               
            }
            $("#DivShow").html(sp);
         
            var tab = "<tr><th style='width:200px;'>借款标题</th><th style='width:120px;'>还款日期</th><th style='width:120px;'>本期应还本息</th><th style='width:120px;'>违约金</th><th style='width:120px;'>催收费</th><th style='width:110px;'>状态</th><th style='width:90px;'>操作</th></tr>";
            for (var i = 0; i < data.Data.length; i++) {
                tab += "<tr><td id='title'>" + data.Data[i].Title + "</td>";
                tab += "<td>" + ChangeDateFormat(data.Data[i].R_RepaymentTime) + "</td>";
                tab += "<td id='RepaymentMoney'>" + data.Data[i].RepaymentMoney + "</td>";
                tab += "<td id='OverdueForfeit'>" + data.Data[i].OverdueForfeit + "</td>";
                tab += "<td id='RushFee'>" + data.Data[i].RushFee + "</td>";
                tab += "<td>" + data.Data[i].PaymentState + "</td>";
                tab += "<td style='align:center'><input type='button' id='but' class='Flat_but radius_5' value = '还款' data-toggle='modal' data-target='#myModal' onclick='upd(" + data.Data[i].MemLoanId + ")' / ></td></tr>";
                $("#TAB").html(tab);
               
            }
            
            
            var tas = "<tr style='background-color:#eddede';><td><span> 共<label id='sums' >" + data.PageCount + "</label>  页&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp当前第 <label id='index'>" + data.PageIndex + "</label> 页&nbsp&nbsp&nbsp&nbsp <a onclick='Page(1)' style='cursor:pointer;'>首页</a>&nbsp&nbsp&nbsp&nbsp";
            //判断当前页是否为1，如果不是那就减一如果是那就直接定到第一页
            if (data.PageIndex <= 1) {
                tas += ("<a  onclick='Page(1)' style='cursor:pointer;' >上一页</a>&nbsp&nbsp&nbsp&nbsp");
            }
            else {
                tas += ("<a  onclick='Page(" + (data.PageIndex - 1) + " )' style='cursor:pointer;' >上一页</a>&nbsp&nbsp&nbsp&nbsp");
            }
            //判断是否为最后一页。如果不是那就加一如果是那就直接定到最后一页
            if (data.PageIndex >= data.PageCount) {
                tas += "<a  onclick='Page(" + (data.PageCount) + " )' style='cursor:pointer;' >下一页</a>&nbsp&nbsp&nbsp&nbsp";
            } else {
                tas += "<a  onclick='Page(" + (data.PageIndex + 1) + ")' style='cursor:pointer;' >下一页</a>&nbsp&nbsp&nbsp&nbsp";
            }
            tas += " <a onclick='Page(" + data.PageCount + ")' style='cursor:pointer;'>尾页</a>&nbsp&nbsp&nbsp&nbsp";

            //跳转页
            tas += "转到&nbsp<input id='pageas' style='width:30px' type='text' />&nbsp&nbsp<input id='Button22' type='button'  style='cursor:pointer;'  onclick='tiaozhuan()'  value='确定' /></span></td> </tr>";
            $("#tab").html(tas);
        });
    };
    //跳转分页
    function tiaozhuan() {
        var idd = $("#pageas").val();
        if (idd > counttt) {
            alert("您输入的页数到达极限！为您跳转到尾页");
            Page(counttt);
        } else {
            Page(idd);
        }
    };
    //搜索
    function sousuoget() {
        $("#startime").val("");//清空开始时间
        $("#endtime").val("");//清空结束时间
        Page(1);
    }
    function sousuos() {
        Page(1);
    }

    function upd(i) {
        $.ajax({
            type: "post",
            url: "/RepayDetailed4/RepayDetailedShowDo",
            data: {
                id:i
            },
            success: function (da) {
                $("#UserId").val(da.UserrId);
                $("#UUserNames").val(da.UserName);
                $("#title3").val(da.Title);
                $("#RepaymentMoney1").val(da.RepaymentMoney);
                $("#URechargeMoney").val(da.RepaymentMoney);
                $("#Rid").val(i)
            }
        })
    }
    function update()
    {
        if($("$Pwd").val()=="")
        {
            $("#Pwd").blur(function(){
                $("#spans").html("✘请输入支付密码！");
                $("$spans").css("color","red");
            })
        }
        else
        {
            $("#Pwd").blur(function(){
                $("#spans").html("✔");
                $("$spans").css("color","green");
            })
        }

    //    $.ajax({
    //        type: "post",
    //        url: "RepayDetailed/RepayDetailedPwd",
    //        data: {
    //            Uid: $("#UserId"),
    //            Upwb: $("#Pwd")
    //        },
    //        success: function (mes) {
    //            if (mes == 1) {
    //            }
    //            else {

    //            }
    //        }
    //    })

    //    $.ajax({
    //        type: "post",
    //        url: "RepayDetailed/UpdateMoney",
    //        data: {
    //        },
    //        success: function (msg) {
    //            if(msg == 1)
    //            {
    //                alert("支付成功！");
    //            }
    //            else {
    //                alert("支付失败！");
    //            }
    //        }
    //    })
        //}





        //function ForPay() {
        //    $.ajax({
        //        url: "/MyAccount/TestPayPwd",
        //        type: "post",
        //        data: {
        //            Paypwd: $("#PayPwd").val(),
        //            Money: $("#RechargeMoney").val(),
        //            PhonePwd: $("#PhonePwd").val()
        //        }, success: function (mes) {
        //            if (mes == 0) {
        //                $("#paypwd").html("✘支付密码不正确")
        //                $("#paypwd").css("color", "red")
        //            }
        //            else {
        //                $("#paypwd").html("")
        //                $("#Testpay").html("✔支付成功")
        //                $("#Testpay").css("color", "green")
        //                location.href = '/MyAccount/MyAccountIndex'
        //            }
        //        }
        //    })
        //}
    }

        </script>

        @*<script type="text/javascript">
        $(document).ready(function () {
            Util.common.CurrentMenu('vt_borrow', 'li_repaymentplan');
            Util.pageTool.init("pageForm", "pageNavTool", function (data) { }, null, "post");
        });

        var showTime = 1500;
        var timeObj = null;
        var a = null;
        var b = null;
        var c = null;
        function SetCall() {
            timeObj = setTimeout("GotoURL()", showTime);
        }
        function GotoURL() {
            $.ajax({
                type: "post",
                url: "getRepaymentNote?subjectId=" + a + "&planId=" + b + "&isRepaymentType=" + c + "&amp;rnd=" + Math.random(),
                contentType: "application/text; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data) {
                        if (data.success == true) {
                            if (data.data != null && data.data['completeOr']) {
                                if (timeObj) {
                                    clearInterval(timeObj);
                                }
                                if (data.data['notes'] != '') {
                                    show(data.data['notes'], true);
                                } else {
                                    show('还款失败,请联系管理员', true);
                                }
                            } else {
                                SetCall();
                            }
                        } else {
                            if (data.code == 400) {
                                SetCall();
                            } else {
                                Util.window.Alert("还款失败,请联系管理员", null, null, function () {
                                    window.location.reload();//刷新当前页面.
                                });
                            }
                        }
                    } else {
                        Util.window.Alert("还款失败,请联系管理员", null, null, function () {
                            window.location.reload();//刷新当前页面.
                        });
                    }
                }
            });
        }

        function repayMent(subjectID, planID, isRepaymentType) {
            Util.window.Confirm("确认还款吗？", function () {
                $.ajax({
                    url: "repay",
                    data: {
                        "subjectID": subjectID,
                        "planID": planID,
                        "isRepaymentType": isRepaymentType
                    },
                    type: "post",
                    cache: false,
                    dataType: "json",
                    success: function (data) {
                        if (data == null) {
                            Util.window.Alert("还款失败,请联系管理员", null, null, function () {
                                window.location.reload();//刷新当前页面.
                            });
                        }
                        if (data.code == 1) {
                            show("请求已提交，正在查询结果。。。。", false);
                            a = subjectID;
                            b = planID;
                            c = isRepaymentType;
                            SetCall();
                        } else {
                            Util.window.Alert(data.message, null, null, function () {
                                window.location.reload();//刷新当前页面.
                            });
                        }

                    },
                    error: function () {
                        Util.window.Alert("还款失败,请联系管理员", null, null, function () {
                            window.location.reload();//刷新当前页面.
                        });
                    }
                });
            }, null, "温馨提示");
        }

        function show(message, clsBtn) {
            $('.dialog3').remove();
            var htmlStr = new Array();
            htmlStr.push("<div class='dialog3' style='z-index:9999999' id='dia_div_'>");
            htmlStr.push("<div class='bg-dialog'></div>");
            htmlStr.push("<div class='dialogBox'>");
            htmlStr.push("<h2 style='font-size: 18px;  font-weight: bolder;'>温馨提示</h2>");
            htmlStr.push("<div class='dialogCon'>");
            htmlStr.push("<div>");
            htmlStr.push("<p>" + message + "</p>");
            htmlStr.push("</div>");
            htmlStr.push("<div class='d-promptBtn'>");
            if (clsBtn) {
                htmlStr.push("<a href='#' name='di_close' class='btn-red btn-save'>确定</a>");
            }
            htmlStr.push("</div>");
            htmlStr.push("</div>");
            htmlStr.push("</div>");
            htmlStr.push("</div>");
            //隐藏层，用来遮罩BODY
            if ($("#bgMask").length == 0) {
                $("body").prepend("<div id='bgMask' style='display:none;'><iframe></iframe></div>");
                $("#dia_div_").css({ "z-index": 999999, "position": "absolute" });
            }
            $("body").prepend(htmlStr.join(""));
            $("#bgMask").show();
            //事件绑定
            $("a[name='di_close']").click(function (e) {
                e.preventDefault();
                $("#bgMask").hide();
                $("#dia_div_").remove();
                window.location.reload();//刷新当前页面.
            });
        }
        function exportRepaymentPlanListsToExcel() {
            var beginTime = $.trim($("#txtStartDate").val());
            var endTime = $.trim($("#txtEndDate").val());
            $("#defaultStartDate").val(beginTime);
            $("#defaultEndDate").val(endTime);
            window.location = "/uac/debit/export?type=2&title=&defaultStartDate=" + beginTime + "&defaultEndDate=" + endTime;
        }
    </script>*@
</div>






